package cn.iot.controller.sys;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.entity.SysLeaveApplication;
import cn.iot.sys.service.SysLeaveApplicationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/sys/leaveApplication")
public class SysLeaveApplicationController {
    @Autowired
    private SysLeaveApplicationService sysLeaveApplicationService;
    private Logger logger = LoggerFactory.getLogger(getClass());

    @PostMapping("getSysLeaveApplicationList")
    public ResultMsg getSysLeaveApplicationList(@RequestParam Map<String,Object> map){
        logger.info("SysLeaveApplicationController getSysLeaveApplicationList map{}",map);
        ResultMsg msg = sysLeaveApplicationService.getSysLeaveApplicationList(map);
        logger.debug("SysLeaveApplicationController getSysLeaveApplicationList msg{}",msg);
        return msg;
    }
    @PostMapping("addSysLeaveApplication")
    public ResultMsg addSysLeaveApplication(@RequestBody SysLeaveApplication sysLeaveApplication){
        logger.info("SysLeaveApplicationController addSysLeaveApplication sysLeaveApplication{}",sysLeaveApplication);
        ResultMsg msg = sysLeaveApplicationService.addSysLeaveApplication(sysLeaveApplication);
        logger.debug("SysLeaveApplicationController addSysLeaveApplication msg{}",msg);
        return msg;
    }

    @PostMapping("updSysLeaveApplication")
    public ResultMsg updSysLeaveApplication(@RequestParam int id){
        logger.info("SysLeaveApplicationController updSysLeaveApplication id{}",id);
        ResultMsg msg = sysLeaveApplicationService.updSysLeaveApplication(id);
        logger.debug("SysLeaveApplicationController updSysLeaveApplication msg{}",msg);
        return msg;
    }

    @PostMapping("getPendingList")
    public ResultMsg getPendingList(@RequestParam Map<String,Object> map){
        logger.info("SysLeaveApplicationController getPendingList map{}",map);
//        ResultMsg msg = new ResultMsg();
        ResultMsg msg = sysLeaveApplicationService.getPendingList(map);
        logger.debug("SysLeaveApplicationController getPendingList msg{}",msg);
        return msg;
    }
    @PostMapping("getProcessedList")
    public ResultMsg getProcessedList(@RequestParam Map<String,Object> map){
        logger.info("SysLeaveApplicationController getProcessedList map{}",map);
//        ResultMsg msg = new ResultMsg();
        ResultMsg msg = sysLeaveApplicationService.getProcessedList(map);
        logger.debug("SysLeaveApplicationController getProcessedList msg{}",msg);
        return msg;
    }

    @PostMapping("approve")
    public ResultMsg approve(@RequestBody SysLeaveApplication sysLeaveApplication){
        logger.info("SysLeaveApplicationController approve sysLeaveApplication{}",sysLeaveApplication);
//        ResultMsg msg = new ResultMsg();
        ResultMsg msg = sysLeaveApplicationService.approve(sysLeaveApplication);
        logger.debug("SysLeaveApplicationController approve msg{}",msg);
        return msg;
    }
    @PostMapping("reject")
    public ResultMsg reject(@RequestBody SysLeaveApplication sysLeaveApplication){
        logger.info("SysLeaveApplicationController reject sysLeaveApplication{}",sysLeaveApplication);
//        ResultMsg msg = new ResultMsg();
        ResultMsg msg = sysLeaveApplicationService.reject(sysLeaveApplication);
        logger.debug("SysLeaveApplicationController reject msg{}",msg);
        return msg;
    }

}
